package cn.bdqn.pn.config;



import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;

import javax.sql.DataSource;

/**
 * 引入所有的数据库配置
 */
@Configuration
public class DataSourceConfig {

    @Bean(name = "baseDataSource")
    @Qualifier("baseDataSource")
    @ConfigurationProperties(prefix = "spring.datasource.base")
    @Primary
    public DataSource oneDataSource(){
        return  DataSourceBuilder.create().build();
    }

    @Bean(name = "commodityDataSource")
    @Qualifier("commodityDataSource")
    @ConfigurationProperties(prefix = "spring.datasource.commodity")
    public DataSource twoDataSource(){
        return  DataSourceBuilder.create().build();
    }


    @Bean(name = "orderDataSource")
    @Qualifier("orderDataSource")
    @ConfigurationProperties(prefix = "spring.datasource.order")
    public DataSource orderDataSource(){
        return  DataSourceBuilder.create().build();
    }

    @Bean(name = "scheduleDataSource")
    @Qualifier("scheduleDataSource")
    @ConfigurationProperties(prefix = "spring.datasource.schedule")
    public DataSource scheduleDataSource(){
        return  DataSourceBuilder.create().build();
    }

    @Bean(name = "userDataSource")
    @Qualifier("userDataSource")
    @ConfigurationProperties(prefix = "spring.datasource.user")
    public DataSource userDataSource(){
        return  DataSourceBuilder.create().build();
    }
}
